<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class UpdateUserRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {

        $validation = array();

	    if ($this->nameHide == $this->name) {
		    $validation['name']='required|min:2|max:20';
	    } else {
		    $validation['name']='required|min:2|max:20|unique:users,name';
	    }

        if ($this->emailHide == $this->email) {
            $validation['email']='required|between:6,100|email';
        } else {
            $validation['email']='required|between:6,100|email|unique:users,email';
        }

        return $validation;

    }
}
